package com.itheima.day05.runtime;

import java.io.IOException;

public class RunTimeTest {
    public static void main(String[] args) throws IOException, InterruptedException {
        //1.创建运行环境对象，runtime为单例对象，构造器私有，需要调用方法创建对象
        Runtime r = Runtime.getRuntime();

        //2.获取运行环境对象中的属性
        //2.1处理器数量
        System.out.println("处理器数量"+r.availableProcessors());
        //2.2JVM总内存
        System.out.println("JVM总内存"+r.totalMemory()/1024/1024);
        //2.3JVM空闲内存
        System.out.println("JVM空闲内存"+r.freeMemory()/1024/1024);
        //2.4启动某个程序,创建一个process对象去接运行的qq程序
        Process p =r.exec("C:\\Program Files (x86)\\Tencent\\QQNT\\QQ.exe");
        //运行5秒钟
        Thread.sleep(5000);
        //p.deestroy()为结束当前运行的程序
        System.out.println("运行结束");
        p.destroy();


    }
}
